<template>
	<view class="u-page">
	<nav-bar title="费用标准详情" :show-right-icon="false"></nav-bar>
		<view class="u-page__item">
			<uni-list>
				<uni-list-item>
					<template v-slot:header>
						<text class="slot-box slot-title">单位名称</text>
					</template>
					<template v-slot:footer>
						<text class="slot-content">{{unitObject.companyname}}</text>
					</template>
				</uni-list-item>
				<uni-list-item>
					<template v-slot:header>
						<text class="slot-box slot-title">车型</text>
					</template>
					<template v-slot:footer>
						<text class="slot-content">{{unitObject.cartypeN}}</text>
					</template>
				</uni-list-item>
				
				<uni-list-item v-for="(item,index) in feeList" :key="index">
					<template v-slot:header>
						<text class="slot-box slot-title">{{item.name}}</text>
					</template>
					<template v-slot:footer>
						<text class="slot-content">{{item.value}}</text>
					</template>
				</uni-list-item>
				
				<!-- <uni-list-item>
					<template v-slot:header>
						<text class="slot-box slot-title">收费方式</text>
					</template>
					<template v-slot:footer>
						<text class="slot-content">{{unitObject.priceunitN}}</text>
					</template>
				</uni-list-item>
				<uni-list-item>
					<template v-slot:header>
						<text class="slot-box slot-title">散租（元/天）</text>
					</template>
					<template v-slot:footer>
						<text class="slot-content">{{unitObject.dayprice}}</text>
					</template>
				</uni-list-item>
				<uni-list-item>
					<template v-slot:header>
						<text class="slot-box slot-title">月租（元/月）</text>
					</template>
					<template v-slot:footer>
						<text class="slot-content">{{unitObject.monthprice	}}</text>
					</template>
				</uni-list-item>
				<uni-list-item>
					<template v-slot:header>
						<text class="slot-box slot-title">半年租（元/半年）</text>
					</template>
					<template v-slot:footer>
						<text class="slot-content">{{unitObject.halfyearprice}}</text>
					</template>
				</uni-list-item>
				<uni-list-item>
					<template v-slot:header>
						<text class="slot-box slot-title">年租（元/年）</text>
					</template>
					<template v-slot:footer>
						<text class="slot-content">{{unitObject.yearprice}}</text>
					</template>
				</uni-list-item>
				<uni-list-item> 
					<template v-slot:header>
						<text class="slot-box slot-title">车辆价值</text>
					</template>
					<template v-slot:footer>
						<text class="slot-content">{{unitObject.prceunittypeN}}</text>
					</template>
				</uni-list-item>-->
				<uni-list-item>
					<template v-slot:header>
						<text class="slot-box slot-title">备注</text>
					</template>
					<template v-slot:footer>
						<text class="slot-content">{{unitObject.seats}}</text>
					</template>
				</uni-list-item>
			</uni-list>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		reactive
	} from 'vue'
	import {
		onLoad,
		onShow
	} from '@dcloudio/uni-app'
	import { getApplyPriceDetail } from '@/api/use';
	import NavBar from '@/components/NavBar.vue';
	const unitId = ref('')
	const unitObject = ref({
		
	})
	const feeList = ref([])
	// 通过事件通道获取单位id
	onLoad((option) => {
		unitId.value = option.id
		serverFeeDetail()
	})
	
	function serverFeeDetail(){
		let params = {
			id:unitId.value
		}
		getApplyPriceDetail(params).then(res => {
			if(res.code === 1){
				unitObject.value = res.data;
				getFeeList(unitObject.value.priceunit)
			}else{
				
			}
		})
	}
	
	function getFeeList(value){
		let gongli = '100';
		let xiaoshi = '10'
		if(value === 1){
			feeList.value.push({
				name:'收费方式',
				value:unitObject.value.priceunitN
			})
			feeList.value.push({
				name:'散租（元/天）',
				value:unitObject.value.dayprice
			})
			feeList.value.push({
				name:'月租（元/月）',
				value:unitObject.value.monthprice
			})
			feeList.value.push({
				name:'半年租（元/半年）',
				value:unitObject.value.halfyearprice
			})
			feeList.value.push({
				name:'年租（元/年）',
				value:unitObject.value.yearprice
			})
			feeList.value.push({
				name:'车辆价值',
				value:unitObject.value.prceunittypeN
			})
		}else {
			if(value === 6){
				gongli = '150'
			}else if(value === 5||value === 9)
			{
				gongli = '200'
			}
			if(value === 3||value === 6||value === 9){
				xiaoshi = '10';
			}else if(value === 4){
				xiaoshi = '4';
			}
			else if(value === 5){
				xiaoshi = '5';
			}else if(value === 7){
				xiaoshi = '6';
			}else if(value === 8){
				xiaoshi = '5';
			}
			feeList.value.push({
				name:'收费方式',
				value:unitObject.value.priceunitN
			})
			feeList.value.push({
				name:gongli+'公里以内（含）包车服务(元/10小时)',
				value:unitObject.value.milprice1
			})
			feeList.value.push({
				name:+gongli+'公里以外包车服务（元/公里）',
				value:unitObject.value.milprice2
			})
			feeList.value.push({
				name:xiaoshi+'小时以外包车服务(元/小时)',
				value:unitObject.value.milprice3
			})
			feeList.value.push({
				name:'核定载客人数',
				value:unitObject.value.prceunittypeN
			})
		}
	}

</script>

<style lang="scss" scoped>
	.u-page {
		padding: 0;

		&__item {
			background-color: #fff;

			&__list {
				display: flex;
				justify-content: space-between;
				margin-bottom: 10px;
				color: #797E84;
				font-size: 13px;

				&__title {
					color: #333;
					font-size: 14px;
				}
			}


			&__title {
				color: #333;
				background-color: #fff;
				padding: 15px;
				font-size: 15px;

				&__slot-title {

					font-size: 14px;
				}
			}

			&__table {
				&__item {
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding: 15px;
					flex: 1;

					&__left {
						color: #797E84;
						font-size: 13px;
					}

					&__right {
						display: flex;
						justify-content: space-around;
						align-items: center;
						color: #333;
						font-size: 14px;

						&__box {
							width: 40px;
							height: 40px;

							text-align: center;

						}
					}
				}
			}
		}
	}

	.u-collapse-content {

		font-size: 14px;
	}
	.slot-content{
		font-size: 16px;
		color: #333;
		float: right;
	}
	.slot-title{
		font-size: 16px;
		color: #999;
	}
</style>